/**
 * @param  {String}  url
 * @param  {Boolean} isNoCaseSensitive 是否区分大小写
 * @return {Object}
 */
// import numeral from 'numeral';

import { Base64 } from 'js-base64';
import JSEncrypt from 'jsencrypt';

export const getWidth = () => {
  return { width: window.innerWidth };
};
export const rsaPsw = (password: string) => {
  const pub =
    `-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwTEExI8ShFeGIeXglACu
vtfJJTgPsCa5nQ0vfcOSaOs4x0xSoGYuMW1nrmUk9QuLgfnukq+kcNvFqRYEnfvi
IWJCbOyxV3XLKjWs598N5MRLfMr/DRXWNJS5xbDbgJkr1VMcyDIOGy0GaOV8qOU4
YylIcssPlWEMTPYDvTx2WTIGt1wDdyBqJ9KyqXgDKvr51vbJVTV3ZNgpLR6MZsyE
c2SMZ0A4uCtKNi9PwrTzJM7LUzihKKlcHaj/Sawpbi9N7FEnxSo7wTeV2s8YfvW2
XgiGjVwDI7iNrFIlwU0Lj9mqoFiUWiTGijEGmrIsnKbkkbxeT3RTzidBIru2KyOw
gwIDAQAB
-----END PUBLIC KEY-----`;
  const encryptor = new JSEncrypt();

  encryptor.setPublicKey(pub);

  return encryptor.encrypt(Base64.encode(password));
};

export default {
  getWidth,
  rsaPsw,
};

export const getFileExtension = (filename: string) =>
  filename.slice(filename.lastIndexOf('.') + 1).toLowerCase();
